/**
 * 
 */
package cn.com.klun.tjy.other.asytask.netty;

import cn.com.klun.tjy.other.asytask.cache.QuartzTaskConfigCache;
import net.sf.json.JSONObject;

import java.io.Serializable;
import java.util.Date;


/**
 * @author chmenmin-ds
 * 客户端与服务端的通讯信息实体
 */
public class NettyMessage implements Serializable{

	private static final long serialVersionUID = 1L;

	/**业务类型*/
	private String businessType;
	
	/**任务实例的唯一值*/
	private String holdKey;
	
	/**推送的信息实体*/
	private JSONObject object;
	
	/**发送请求的时间*/
	private Date requestTime;
	
	/**发送响应的时间*/
	private Date responseTime;
	
	/**业务值传输*/
	private JSONObject jsonObject;
	
	/**业务值传输*/
	private String requestKey;

	private volatile boolean sendRequestOK = true;
	
	public NettyMessage(){
		this.jsonObject = new JSONObject();
		this.holdKey = QuartzTaskConfigCache.getHoldKey();
		this.requestTime = new Date();
	}
	
	public NettyMessage(String businessType){
		this.jsonObject = new JSONObject();
		this.holdKey = QuartzTaskConfigCache.getHoldKey();
		this.requestTime = new Date();
		this.businessType = businessType;
	}
	
	public JSONObject getJsonObject() {
		return jsonObject;
	}

	/**设置业务值到对象中*/
	public void setJsonObject(String key,Object value){
		jsonObject.put(key, value);
	}
	
	/**获取业务值到对象中*/
	public Object getJsonObject(String key){
		return jsonObject.get(key);
	}
	
	/**调用方向：1，向服务端；2，向客户端*/
	private int type;

	public String getBusinessType() {
		return businessType;
	}

	public void setBusinessType(String businessType) {
		this.businessType = businessType;
	}

	public String getHoldKey() {
		return holdKey;
	}

	public void setHoldKey(String holdKey) {
		this.holdKey = holdKey;
	}

	public JSONObject getObject() {
		return object;
	}

	public void setObject(JSONObject object) {
		this.object = object;
	}

	public Date getRequestTime() {
		return requestTime;
	}

	public void setRequestTime(Date requestTime) {
		this.requestTime = requestTime;
	}

	public Date getResponseTime() {
		return responseTime;
	}

	public void setResponseTime(Date responseTime) {
		this.responseTime = responseTime;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getRequestKey() {
		return requestKey;
	}

	public void setRequestKey(String requestKey) {
		this.requestKey = requestKey;
	}

	public boolean isSendRequestOK() {
		return sendRequestOK;
	}

	public void setSendRequestOK(boolean sendRequestOK) {
		this.sendRequestOK = sendRequestOK;
	}
}
